/*
 * cubeLinkedList.h
 *
 * A simple linked list for IDA* algorithm
 *
 *
 */

#ifndef CUBEQUEUE_H_
#define CUBEQUEUE_H_

#include <stdbool.h>
#include "cube.h"

typedef struct LLNode LLNode;

//Internal linked list struct
struct LLNode {
    // the face turned
    char faces[40];
    // the number of turns per face, one value per face (should always be the same size as faces)
    char turns[40];
    //Where in the array to put next face
    uint32_t nxt_pos;
    //where in the array the storage starts
    uint32_t start_pos;
    
    //The previous node in the linked list
    LLNode *prev;
};

typedef struct LinkedList {
    LLNode *head;
    LLNode *tail;
} LinkedList;

/*
 * Remove the item from the head of the linked list
 *
 * @param ll The linked list to dequeue from
 *
 * @return The Cube state at the head of the linked list
 */
char del(LinkedList *ll);

/*
 * Add an item to a linked list
 *
 * @param[out] ll A pointer to the linked list state to add a node to
 * @param face The face state to add to the queue
 */
void add(LinkedList *ll, char face);

/*
 * initializes a linked list
 * Must be called prior to linked list use
 *
 * @param ll A pointer to the linked list to initialize
 */
void initLinkedList(LinkedList *ll);

/*
 * Check if a linked list is empty
 *
 * @param ll The linked list to check
 *
 * @return true if the linked list is empty
 */
bool isLLEmpty(LinkedList *const ll);


void reduce(LinkedList *ll);

#endif /* CUBEQUEUE_H_ */